<?php

namespace Orm\TrackLog;

class TrackLogModel extends \Base\BaseOrmModel
{

    function __construct()
    {
        parent::__construct();
        $this->table = 't_track_log';
    }

    /**
     * 获取上线人数
     * @param $start_time
     * @param $end_time
     */
    public function getOnlineCustomerNum($start_time, $end_time)
    {
        $sql = "SELECT
                    count( DISTINCT uid ) as customer_count
                FROM
                    `t_track_log` AS t
                    LEFT JOIN `t_customer` c ON c.id = t.uid 
                WHERE
                    t.insert_time BETWEEN '{$start_time}' AND  '{$end_time}'
                    AND c.type = 2 
                    AND t.uid !=0
                    AND t.is_del = 0;";
        $result = $this->_fetch($sql, 1);
        return $result[0]['customer_count'];
    }

}